package com.heima.common.util;

import com.heima.common.dto.User;

/**
 * @author zsk
 * @create 2022-04-12-16:36
 */
public class MediaThreadLocalUtil {

    //定义ThreadLocal
    private static ThreadLocal<User> threadLocal = new ThreadLocal<>();

    //设置用户id
    public static void set(User user){
        threadLocal.set(user);
    }

    //获取用户di
    public static User get(){
        return threadLocal.get();
    }

    //删除本地线程，防止内存泄露
    public static void remove(){
        threadLocal.remove();
    }

}
